ast-grep: Atomic Rule
from ast-grep: Rule Object
#wip
ast-grep: Atomic Rule
ASTノードが一致するかどうかをチェックする基本的もの
https://zenn.dev/makotot/articles/ea823805582e5c#atomicルール
https://ast-grep.github.io/reference/rule.html#atomic-rules
https://ast-grep.github.io/guide/rule-config/atomic-rule.html
以下の3つ
pattern
ただのast-grepのPatternと思いきやseclectorなどのfieldもあるらしい
code:yml
pattern:
selector: field_definition
context: class { $F }
selectorに指定する値はtree-sitterのノード名だと思う。Playgroundで確認してみたりすると分かるけど、JavaScriptとTypeScriptでも微妙に異なるノード名だったりする。ref
ムズいなあmrsekut.icon
ast-grepのplaygroundを見るのは大前提、という感じなのかな
https://ast-grep.github.io/advanced/match-algorithm.html
kind
ASTのノードの種別で絞り込む
tree-sitterかなにかの実装の詳細(?)を知らないとわからないmrsekut.icon
regex
nthChild